var dayjs = require('./dayjs.min.js')
const gdshopCache = {
  
}

gdshopCache.set = (key,value,expire = 0) => {
	if (expire === 0){
		expire = 30 * 86400 + dayjs().unix()
	} else {
		expire = dayjs().unix() + expire
	}
	uni.setStorageSync(key + '-expire',expire)
	uni.setStorageSync(key,value)
}

gdshopCache.get = (key) => {
	const expire = uni.getStorageSync(key + '-expire');
	if (!expire){
		return null
	}
	const now = dayjs().unix()
	if (now > expire){
		return null
	}
	return uni.getStorageSync(key);
}

export default gdshopCache